FFI: Generic getter(s) for X.509 objects - #5188
Conversation
|
I'm not firmly against it. I would definitely suggest view-style functions since, with cases like this where the lengths can be somewhat open-ended (especially so given the set of fields might be expanded over time), retry handling is kind of a pain. OTOH if we have a single kind of getter dispatch function, is there really that much duplication to have 2 instead, one for certs and one for CRLs? One thing I did try for in the FFI interface is making it a type safe as possible when used from C. (This stems from the fact that a major driver of the FFI interface as it exists today is due to the requirements of RNP, which at the time was written entirely in C). This function which will require a cast for either input type bypasses that a bit, and tbh I don't really see how 2 type specific getter-dispatchers would be a problem, admittedly I'm not at all familiar with strongswan internals. |
👍
No, we could split it up. Perhaps the boilerplate might grow a bit faster once we introduce additional getters for strings, lists and such. Mostly I was interested in exploring the ergonomics of such a unified API. That said, I think I'll leave it in until the work on the strongswan plugin converges. Reverting this won't be a lot of work anyway. |
f81c4fb to
28c62c5
Compare
0324a33 to
08c8fae
Compare
|
In my opinion this is now ready-for-review. Documentation as well as PR description is updated accordingly.
I split the functions into CRL/cert as proposed. The required overhead indeed does not justify the added complexity in the API contract as well as the underlying implementation of the polymorphy. The potential extension discussed in an inline thread would make a lot of sense, in my opinion. Some details may need further discussion though, so I would suggest to split this off into another PR. |
08c8fae to
7dacff2
Compare
|
Could you increase the FFI version? Would be nice if it could be the intended release date like outlined here. Also any plans for an impl for the python binding, or should that happen at a later date by someone(tm)? :p |
Shouldn't be too hard to do. I would leave it to a future step though, once the API in this is finalized. |
8cc4c61 to
9824817
Compare
9824817 to
6b8cb78
Compare
This comment was marked as resolved.
This comment was marked as resolved.
6b8cb78 to
73ba696
Compare
|
I've added Re: |
73ba696 to
4497a60
Compare
a6a6401 to
9d9388a
Compare
|
@reneme Shit sorry I thought this had already landed on master. Looks goods to me, needs a rebase though. |
9d9388a to
dc8b17a
Compare
Namely: * botan_x509_cert_view_binary_values * botan_x509_cert_view_string_values * botan_x509_crl_view_binary_values * botan_x509_crl_view_string_values This allows fetching standard information from X.509 objects such as the serial number of both a certificate and a CRL but also more specific information like OCSP responder URLs. Some getter types may have more than one value. For such cases, the getters have an index parameter to enumerate all elements.
These functions are currently implemented by trivially counting the number of elements their associated enumerator functions are actually producing. Given that most values are anyway viewed straight from the C++ objects' memory, the overhead should be negligible. The main advantage of this approach is its minimal maintenance burden.
dc8b17a to
525e34c
Compare
... actually, me too. We're still waiting on another team to test run this in their system and it fully disappeared from my short term memory. Thanks for noticing and moving it forward. I applied your suggestion re:"assert unreachable" and rebased to master (testing locally that it compiles/unittests with |
|
@randombit This is now rebased and ready to go. I can haz ✅ plz? |
We're currently working on extending the strongswan botan plugin to parse and verify X.509 certificates and CRLs using Botan. That use case requires adding a number of new getters to fetch detailed information from certificates and CRLs, many of which are duplicated for both types like the raw signature bits, the serial number or the (optional) authority key ID.
Instead of extending the FFI with several new functions (including the duplication for
botan_x509_cert_tandbotan_x509_crl_t) we would like to propose a more generic API that can work with both types and provide access to a number of (shared) data fields, like so:Our hope is that this significantly reduces the boilerplate and API surface while also being easily extensible by amending the "type enum" in an ABI-compatible way. Note that the proposed API allows to access multi-value fields using a simple index parameter.
Currently, the following data fields can be retrieved via this API: